package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.*;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author gaozhengxing gaozhenghang@wondertek.com.cn
 * @date 2020/12/31 17:00
 * @description TODO
 */
@Data
@Entity
@Table(name = "SELLING_PRICE_LOG")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SellingPriceLog implements Serializable {

    private static final long serialVersionUID = 6852432309562204276L;

    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "SELLING_PRICE_LOG_SEQ")
    @SequenceGenerator(name = "SELLING_PRICE_LOG_SEQ", allocationSize = 1, sequenceName = "SELLING_PRICE_LOG_SEQ")
    private Long id;

    /**是否在售*/
    @Column(name = "IS_SAL")
    private String isSal="1";
    /**操作时间*/
    @Column(name = "OPERATE_TIME")
    private String operateTime;
    @Column(name = "OPERATOR")
    private String operator;
    @Column(name = "OPT_TYPE")
    private String optType="1";
    @Column(name = "SAL_END_TIME")
    private String salEndTime;
    @Column(name = "SAL_START_TIME")
    private String salStartTime;
    @Column(name = "CONTENT_ID")
    private String contentId;
    @Column(name = "NAME")
    private String name;
    @Column(name = "PRDCONT_ID")
    private String prdContId;
    @Column(name = "PRODUCT_ID")
    private String productId;
    @Column(name = "PRDINFO_ID")
    private String prdInfoId;
    /**定价*/
    @Column(name = "PRICE")
    private String price;
    /**基本计费产品名称*/
    @Column(name = "PRODUCT_NAME")
    private String productName;

    public static void putTimeAndUser(SellingPriceLog sellingPriceLog) {
        sellingPriceLog.setOperator(CurrentUser.currUserName());
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString = formatter.format(currentTime);
        sellingPriceLog.setOperateTime(dateString);
    }

}